# -*-coding:utf-8 -*-
"""
专题报表-沪深股票-沪深港通-沪深港通额度信息统计表
"""
from EmQuantAPI import *
import common.mainApi as mp
import common.handler_date_time as hd_dt
import common.handler_ctr_result as hd_cr
import common.dataFrame as df
import common.sql as db
import common.mainApi as ma
import config.base_info as bs

base_type = "ctr"
base_target = "target"
base_index = "QuotaSHSZHKInfo"

info_ = bs.INDEX_INFO.get(base_type).get(base_target).get(base_index)  # ->dict
param_code = info_.get("return_data")  # ->list
param_ = ",".join(param_code)
option_ = "StartDate={0},EndDate={1}"


def mainQuotaSHSZHKInfo(startDate="2021-03-22",endDate="2021-03-25"):
   
    data = c.ctr(base_index, param_, option_.format(startDate,endDate))

    return data

if __name__ == "__main__":
    mp.login()
    #startDate="2019-09-01"
    #endDate="2019-12-31"
    startDate="2021-04-28" #
    endDate="2021-04-28"
    trade_date=hd_dt.getDateOfCycle(start_date=startDate,end_date=endDate)
    for i in trade_date:
        data=mainQuotaSHSZHKInfo(startDate=startDate,endDate=i)
        hd_cr.ctr_result_handler(data_res=data,index_=base_index)
    mp.stop()
    db.dbcon_dispose() #close-db



